package com.example.springboot159.Listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.listener.MessageListener;
import org.springframework.stereotype.Component;

@Component
public class MyKafkaMessageListener implements MessageListener<String, String> {
    public final static Logger logger = LoggerFactory.getLogger(MyKafkaMessageListener.class);

    @Override
    public void onMessage(ConsumerRecord<String, String> data) {
        System.out.println("data:"+data);
        String topic=data.topic();
        logger.info("topic:"+topic);
        logger.info("partition:"+String.valueOf(data.partition()));
        logger.info("offset:"+String.valueOf(data.offset()));
        logger.info("value:"+data.value());
    }
}